#ifndef MOUSETRACKER_H
#define MOUSETRACKER_H

#include <QObject>
#include <QMutex>
#include <QThread>
#include <QFile>
#include <QSocketNotifier>
#include "AutoPropertyHelper.h"
#include "quicktool.h"

class MouseTrackingWorker;  // 前向声明 MouseTrackingWorker 类

class MouseTracker : public QObject
{
    Q_OBJECT

public:
    static MouseTracker& getInstance() {
        static MouseTracker instance;
        return instance;
    }
    ~MouseTracker();

    OR_QML_STATE_PROPERTY(double , mouceMoveDistance , 0)
    AUTO_CONFIG_PROPERTY(MouseTracker,"base", float , fabricSpacing)
    AUTO_CONFIG_PROPERTY(MouseTracker,"base", float , fabricSpacingOnce)
    AUTO_CONFIG_PROPERTY(MouseTracker,"base", float , fabricSpacingStop)
    Q_INVOKABLE double getMoveDistance();  // 获取移动距离
    const QString devicePath = "/dev/mouse_sensor";




    int getMoveDistanceAct();
private:
    explicit MouseTracker( QObject *parent = nullptr);  // 私有构造函数
    MouseTracker(const MouseTracker&) = delete;
    MouseTracker& operator=(const MouseTracker&) = delete;

    static MouseTracker* instance;  // 单例实例
    MouseTrackingWorker *worker;  // 鼠标追踪工作线程
    QThread *workerThread;
    int lastX, lastY;
    int currentX, currentY;
};

#endif // MOUSETRACKER_H
